package nccloud.web.pu.poorder.action;

import nc.vo.pu.m21.entity.OrderItemVO;
import nc.vo.pub.BusinessException;
import nccloud.dto.pu.poorder.entity.QueryInfo;
import nccloud.framework.service.ServiceLocator;
import nccloud.framework.web.action.itf.ICommonAction;
import nccloud.framework.web.container.IRequest;
import nccloud.framework.web.json.JsonFactory;
import nccloud.framework.web.ui.pattern.grid.Grid;
import nccloud.framework.web.ui.pattern.grid.GridOperator;
import nccloud.pubitf.pu.service.IPUOrderExtServer;

public class YtmxQueryAction implements ICommonAction{

	@Override
	public Object doAction(IRequest request) {
		String read = request.read();
		QueryInfo info = (QueryInfo)JsonFactory.create().fromJson(read, QueryInfo.class);
		String[] pks = info.getPks();
		if (pks == null || pks.length == 0) {
			return null;
		}
		
		Grid grid = null;
		OrderItemVO[] vos = null;
		
		try {
			vos = ServiceLocator.find(IPUOrderExtServer.class).queryDetailsByHpks(pks);
			
		} catch (BusinessException e) {
			e.printStackTrace();
		}
		
		if (vos == null) {
			return grid;
		}
		
		GridOperator operator = new GridOperator(info.getPageid());
		grid = operator.toGrid(vos);
		return grid;
	}

}
